package domean;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;

import javax.swing.JComponent;

public class Spielfigur extends JComponent{

	private int XKoordinate;
	private int YKorrdinate;
	private int radius1 = 15;
	private int radius2 = 10;
	private int zelle = -1;
	private String nummer;
	private Font font;
	private boolean figurAufFeld = false;
	
	private Color farbe;
	
	public Spielfigur(int x, int y, Color farbe, int nummer){
		this.XKoordinate = x;
		this.YKorrdinate = y;
		this.farbe = farbe;
		if(nummer == 0){
			this.nummer = "";
		}else{
			this.nummer = String.valueOf(nummer);
		}
		this.setLocation(x, y);
		this.setPreferredSize(new Dimension(radius1, radius1));
		this.setSize(new Dimension(radius1, radius1));

		this.font = new Font( "Verdana", Font.BOLD, 12 );
		//Test
//		setBorder(BorderFactory.createLineBorder(Color.white));
	}
	
	public Spielfigur(){
		
	}
	
	public void paintComponent(Graphics gr) {
		Graphics2D graphics  = (Graphics2D) gr;
		graphics.setColor(this.farbe);
		graphics.fillOval(0, 0, radius1, radius1);
		graphics.setColor(Color.WHITE);
		graphics.fillOval(3, 3, radius2, radius2);
		graphics.setColor(Color.BLACK);
		graphics.setFont(this.font);
		graphics.drawString(nummer, 4, 12);
	}

	/**
	 * getter fuer <code>{@link #XKoordinate}</code>
	 */
	public int getXKoordinate() {
		return XKoordinate;
	}

	/**
	 *  setter fuer <code>{@link #XKoordinate}</code>
	 */
	public void setXKoordinate(int xKoordinate) {
		XKoordinate = xKoordinate;
	}

	/**
	 * getter fuer <code>{@link #YKorrdinate}</code>
	 */
	public int getYKorrdinate() {
		return YKorrdinate;
	}

	/**
	 *  setter fuer <code>{@link #YKorrdinate}</code>
	 */
	public void setYKorrdinate(int yKorrdinate) {
		YKorrdinate = yKorrdinate;
	}

	/**
	 * getter fuer <code>{@link #farbe}</code>
	 */
	public Color getFarbe() {
		return farbe;
	}

	/**
	 *  setter fuer <code>{@link #farbe}</code>
	 */
	public void setFarbe(Color farbe) {
		this.farbe = farbe;
	}
	
	/**
	 * getter fuer <code>{@link #zelle}</code>
	 */
	public int getZelle() {
		return zelle;
	}

	/**
	 *  setter fuer <code>{@link #zelle}</code>
	 */
	public void setZelle(int zelle) {
		this.zelle = zelle;
	}

	/**
	 * getter fuer <code>{@link #figurAufFeld}</code>
	 */
	public boolean isFigurAufFeld() {
		return figurAufFeld;
	}

	/**
	 *  setter fuer <code>{@link #figurAufFeld}</code>
	 */
	public void setFigurAufFeld(boolean figurAufFeld) {
		this.figurAufFeld = figurAufFeld;
	}
	
	public String getNummer(){
		return this.nummer;
	}
}
